<cfcomponent extends="CFHibernateAbstractTest">


<!---
				 daFactory = CreateObject ("Java","coldfusion.server.ServiceFactory");
				 daConnection = daFactory.getDataSourceService().getDatasource(dataSource).getConnection();


	<cffunction name="testHbm2hbm" returntype="void" access="public">
		<cfset var results = variables.hibernatefactory.generate() />
		<cfset var hibConfig = variables.hibernatefactory.configure() />
			<cfset sessionFactory = hibConfig.buildSessionFactory() />
			<cfset hibSession = sessionFactory.getCurrentSession() />
			<cfset hibSession.beginTransaction() />
	   <cftry>			
			<cfset result = hibSession.createQuery("from Users").list()/>
			<cfset hibSession.getTransaction().commit() />			
			<cfset sessionFactory.close() />
	   	<cfcatch><cfoutput>#cfcatch.message#</cfoutput><cfabort></cfcatch>
		</cftry>
		<cfoutput>
		   <cfloop from="1" to="#arrayLen(result)#" index="e">
		   		<cfset i = result[e]>
		      #i.getUserId()# - #i.getUsername()# - #i.getEmail()#<br />
		   </cfloop>
		</cfoutput>			
<cfabort/>
		<cfset assertComplexValue(value=results) />
	</cffunction>
--->		

<!---
	<cffunction name="testJdbc2hbm" returntype="void" access="public">
		<cfset var results = variables.hibernatefactory.hbmgen("/actionpacks/cfhibernate/tests/config/hibernate.cfg.xml",
							"/actionpacks/cfhibernate/tests/config/",
							"/actionpacks/cfhibernate/tests/config/cfhibernatejar/") />
							<cfdump var="#results#"><cfabort />
		<cfset assertComplexValue(value=results) />
	</cffunction>

	<cffunction name="testGenerate" returntype="void" access="public">
		<cfscript>
			var results = variables.hibernatefactory.generate();
		</cfscript>
	</cffunction>
--->		


	<cffunction name="testHbm2hbm" returntype="void" access="public">
		<!--- create jar of HBMs so the config can find them (why straight path doesn't work I don't know) --->
		<cfset var jar = variables.hibernatefactory.createJarFile(							
							variables.hbmsLocation & "cfhibernate",
							variables.hbmsJarLocation) />
		<!--- create java files --->
		<cfset var results = variables.hibernatefactory.javagen("/actionpacks/cfhibernate/tests/config/hibernate.cfg.xml",
							variables.hbmsJarLocation,
							variables.srcLocation) />
			<!--- compile the files --->
		<cfset var compile = variables.hibernatefactory.compile(variables.srcLocation,"",hbmsLocation)/>
		<!--- create jar of HBMs and Class files so the config can find them (why straight path doesn't work I don't know) --->
		<cfset var jarWithClasses = variables.hibernatefactory.createJarFile(							
							variables.hbmsLocation & "cfhibernate",
							variables.hbmsJarLocation) />
							
		<cfset var addJar = variables.hibConfig.addHbmLocation(variables.hbmsJarLocation) />
		<cfset var sessionFactory = variables.hibConfig.buildSessionFactory() />
		<cfset var currentSession = "" />
		<cfset var theEvent = "" />
		
    <cfscript>
			try {
		 		currentSession = sessionFactory.openSession();
        currentSession.beginTransaction();

				theEvent = variables.hibernatefactory.create("cfhibernate.tests.Events").newInstance();
		    theEvent.setEventname("A Test Event");
		    theEvent.setEventdate(now());
		    currentSession.save(theEvent);
        currentSession.getTransaction().commit();

				currentSession.beginTransaction();
				person = variables.hibernatefactory.create("cfhibernate.tests.People").newInstance();
		    person.setFirstname("Ted");
		    person.setLastname("Nugent");
		    person.getEvents().add(event);
//		    event.getParticipants().add(person);

		    currentSession.save(person);

        currentSession.getTransaction().commit();

			
				currentSession.beginTransaction();
				result = currentSession.createQuery("from Events").list();
				currentSession.getTransaction().commit();

			} 
			catch(Any excpt) {
				// dump of struct is endless loop do to cf introspection haywireness so just do msg/stack
			  dumpvar(excpt.message & " " & excpt.stacktrace);
			}
		</cfscript>
		<cfoutput>
		   <cfloop from="1" to="#arrayLen(result)#" index="e">
		   		<cfset i = result[e]>
		      #i.getEventname()# - #i.getEventDate()#<br />
		      <cfset personIterator = i.getParticipants().iterator() />
				   <cfloop condition="#personIterator.hasNext()#">
					   <cfset p = personIterator.next() />
				      #p.getFirstname()# - #p.getLastname()#<br />
				   </cfloop>

		   </cfloop>
		</cfoutput>
		<cfabort />


			<cfdump var="#sessionFactory#" /><cfabort />

	<cftry>
			<cfset sessionFactory = variables.hibConfig.buildSessionFactory() />
			<cfset hibSession = sessionFactory.openSession() />
			<cfset hibSession.beginTransaction() />
			<cfset result = hibSession.createQuery("from Users").list()/>
			<cfset hibSession.getTransaction().commit() />			
			<cfset sessionFactory.close() />
	   	<cfcatch><cfoutput>#cfcatch.message#</cfoutput><cfabort></cfcatch>
		</cftry>
		<cfoutput>
		   <cfloop from="1" to="#arrayLen(result)#" index="e">
		   		<cfset i = result[e]>
		      #i.getUserId()# - #i.getUsername()# - #i.getEmail()#<br />
		   </cfloop>
		</cfoutput>			
		<cfabort/>

		<cfset assertComplexValue(value=results) />
	</cffunction>
--->		

</cfcomponent>
